"use strict";
const db = uniCloud.database();
const dbCmd = db.command;
exports.main = async (event, context) => {
	const {
		userId
	} = event;
	//获取我的文章
	let user = await db.collection('user').doc(userId).get()
	let article_ids = user.data[0].article_ids;

	let list = await db.collection('article')
		.aggregate()
		.project({
			content: 0,
			comments: 0
		})
		.match({
			id: dbCmd.in(article_ids)
		})
		.end()

	return {
		code: 0,
		msg: "获取我的文章成功",
		data: list.data
	}
};